# -*- mode: snippet -*-
# name: optimize/optimise with integer
# key: optimize_with_integer
# contributor : Shuguang Sun
# --
${1:already_visited} <- 0L

optimize(
  function(${2:n}) {
    ${3:nf} <- floor($2)

    if (abs($1 - $3) < 0.5) {
      0
    } else {
      $1 <<- $3
      ${99:()^2}
    }
  },
  interval = c(20, 1000)
)$minimum
